﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Actuals.CoreDomain;
using Actuals.CoreDomain.Business;

namespace Actuals.Business
{
    public class BusinessActualBreakDownDashBoard : IBusinessActualBreakDownDashBoard
    {
          private IBusinessActualsBreakDown  _businessActualsBreakDown;

        public BusinessActualBreakDownDashBoard(IBusinessActualsBreakDown businessActualsBreakDown)
        {
            _businessActualsBreakDown = businessActualsBreakDown;
        }

        public BusinessActualBreakDownDashBoard()
        {
            _businessActualsBreakDown = new BusinessActualsBreakDown();
        }

        public IActualBreakDownDashBoard GetActualBreakDownDashBoard(DateTime fromDate, DateTime toDate)
        {
            IActualBreakDownDashBoard actualBreakDownDashBoard = new ActualBreakDownDashBoard();

            IList<IActualBreakDown> _actualsForDevelopers = _businessActualsBreakDown.
                 GetActualsBreakDownForDevelopers(fromDate, toDate, 0, 0);
            IList<IActualBreakDown> _actualsForba = _businessActualsBreakDown.
               GetActualsBreakDownForBusinessAnalysts(fromDate, toDate, 0, 0);

            actualBreakDownDashBoard.DevelopersBreakDown = _actualsForDevelopers;
            actualBreakDownDashBoard.DevelopersTotal = _businessActualsBreakDown.GetTotalHours(_actualsForDevelopers);


            actualBreakDownDashBoard.BusinessAnalystsBreakDown = _actualsForba;
            actualBreakDownDashBoard.BusinessAnalystTotal = _businessActualsBreakDown.GetTotalHours(_actualsForba);

            return actualBreakDownDashBoard;

        }

        public IActualBreakDownDashBoard GetActualBreakDownDashBoard(DateTime fromDate, DateTime toDate, int projectId, int releaseId)
        {
            IActualBreakDownDashBoard actualBreakDownDashBoard = new ActualBreakDownDashBoard();
            
            IList<IActualBreakDown> _actualsForDevelopers = _businessActualsBreakDown.
                 GetActualsBreakDownForDevelopers(fromDate, toDate, projectId, releaseId);
            IList<IActualBreakDown> _actualsForba = _businessActualsBreakDown.
               GetActualsBreakDownForBusinessAnalysts(fromDate, toDate, projectId, releaseId);

            actualBreakDownDashBoard.DevelopersBreakDown = _actualsForDevelopers;
            actualBreakDownDashBoard.DevelopersTotal = _businessActualsBreakDown.GetTotalHours(_actualsForDevelopers);


            actualBreakDownDashBoard.BusinessAnalystsBreakDown = _actualsForba;
            actualBreakDownDashBoard.BusinessAnalystTotal = _businessActualsBreakDown.GetTotalHours(_actualsForba);

            return actualBreakDownDashBoard;

        }
    }
}
